<?php

class UslugiController extends Controller {

	public function actionIndex() {

		$data = parent::$pageData;
		$this->pageTitle = $data['pageTitle'] . ' — Моби03';
		Yii::app()->clientScript->registerMetaTag('', 'description');
		Yii::app()->clientScript->registerMetaTag($data['pageTitle'], 'keywords');
		$criteria = new CDbCriteria();
		$criteria->compare('"pageActive"', 1);
		$criteria->compare('"pageType"', 'service');

		$criteria->order = '"pageCreateDate" desc';
		$count = Page::model()->count($criteria);
		$pages = new CPagination($count);
		$pages->pageSize = 10;
		$pages->applyLimit($criteria);
		$models = Page::model()->findAll($criteria);
		$this->render('index', array('models' => $models, 'pages' => $pages));
	}

	public function actionView() {
		foreach (Yii::app()->params['regions'] as $key => $value) {
			$regions[] = $value['genitive'];
		}
		$regions = implode(', ', $regions);
		$data = parent::$pageData;
		$this->pageTitle = !empty($data['metaTitle']) ? $data['metaTitle'] : $data['pageTitle'] . ' в ' . $regions . ' — Моби03';
		Yii::app()->clientScript->registerMetaTag($data['metaDesc'], 'description');
		Yii::app()->clientScript->registerMetaTag($data['metaKeywords'], 'keywords');
		$this->render('view', array('data' => $data));
	}

}
